#include "FrameRate.h"


FrameRate::FrameRate(float tfps)
{
	targetfps = tfps;
	speedfactor = 1;
	QueryPerformanceCounter(&framedelay);
	QueryPerformanceFrequency(&tickspersecond);

	loops = 0;
	media = 0.f;
}

void FrameRate::SetSpeedFactor(){
	QueryPerformanceCounter(&currentticks);
	//This frame's length out of desired length
	speedfactor = (float)(currentticks.QuadPart-framedelay.QuadPart)/((float)tickspersecond.QuadPart/targetfps);
	fps = targetfps/speedfactor;
	if (speedfactor <= 0)
		speedfactor = 1;

	framedelay = currentticks;
	}
FrameRate::~FrameRate(void)
	{
	}
